@extends('admin.layout.main')
@section('content')
    <!-- iCheck for checkboxes and radio inputs -->
    <link rel="stylesheet" href="{{asset('/adminlte/plugins/iCheck/all.css')}}">
    <section class="content-header">
      <h1>
        通知列表
      </h1>
      <ol class="breadcrumb">
        <li><a href="javascript:void(0)"><i class="fa fa-dashboard"></i> 全网通知</a></li>
      </ol>
    </section>
    <section class="content">
        <!-- Small boxes (Stat box) -->
        <div class="row">
            <div class="col-lg-12 col-xs-6">
                <div class="box">
                    <div class="box-header with-border">
                        <div class="row">
                            <div class="col-sm-10">
                                <a href="javascript:void(0)" class="add-cast"><i class="fa fa-fw fa-plus"></i>新增通知</a>
                            </div>
                        </div>
                    </div>
                    
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover" id="user-list">
                            <div class="dataTables_filter">
                                <form action="" method="GET">
                                    <button type="submit" class="btn btn-info btn-sm">查询:</button><input type="search" placeholder="请输入关键字" name="keywords" class="form-control input-sm" value="{{$keywords}}">
                                </form>
                            </div>
                            <thead>
                                <tr>
                                    <th style="width: 50px"><a style="cursor:pointer" class="all_check">全选</a></th>
                                    <th>标题</th>
                                    <th>内容</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody> 
                                @foreach($casts as $cast)
                                    <tr id="{{$cast->id}}">
                                        <td>
                                            <input type="checkbox" name="checkbox_member" class="checkbox_member" user-id="{{$cast->id}}">
                                        </td>
                                        <td>{{$cast->title}}</td>
                                        <td>{{ mb_substr($cast->content, 0, 20) }}...</td>
                                        <td>
                                            <a href="javascript:void(0)" class="edit-cast"><i class="fa fa-fw fa-eye"></i>详情</a>
                                            <a href="javascript:void(0)" class="delete-cast"><i class="fa fa-fw fa-remove"></i>删除</a>
                                            <a href="javascript:void(0)" class="voice-cast"><i class="fa fa-bullhorn"></i>广播</a>
                                            <a href="javascript:void(0)" class="log-cast"><i class="fa fa-fw fa-book"></i>日志</a>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                        {{$casts->links()}}
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- datepicker -->
    <script src="{{asset('/adminlte/plugins/datepicker/bootstrap-datepicker.js')}}"></script>
    <!-- iCheck 1.0.1 -->
    <script src="{{asset('/adminlte/plugins/iCheck/icheck.min.js')}}"></script>
    <script type="text/javascript">
        $(function () {
            $('#user-list').DataTable({
              "paging": false,
              "lengthChange": false,
              "searching": false,
              "info": false,
              "autoWidth": true,
              "columns": [
                {"orderable": false},
                {"orderable": false},
                {"orderable": false},
                {"orderable": false}
              ]
            });
        });

        $('.all_check').click(function(){
            $('.checkbox_member').click();
        });

        $('#datepicker').datepicker({
          autoclose: true,
          endDate: new Date()
        });

        $('.add-cast').click(function(){
            dialog_params('/admin/broadcast/create', '新增通知');
        });

        $('.edit-cast').click(function(){
            var id = $(this).parents('tr').attr('id');
            dialog_params('/admin/broadcast/edit/'+id, '编辑通知');
        });

        $('.delete-cast').click(function(){
            var id = $(this).parents('tr').attr('id');
            dialog_params('/admin/broadcast/delete/'+id, '删除通知');
        });

        $('.voice-cast').click(function(){
            var id = $(this).parents('tr').attr('id');
            dialog_params('/admin/broadcast/voice/'+id, '发送通知');
        });

        $('.log-cast').click(function(){
            var id = $(this).parents('tr').attr('id');
            dialog_group('/admin/broadcast/log/'+id, '日志记录');
        });


    </script>
@endsection      